package com.example.demo.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 基础实体类
 *
 * @author lst
 * @since 2019-12-17
 * @param <T>
 */
@Data
public class BasePlusEntity<T extends Model> extends Model implements Serializable {

    private static final long serialVersionUID = 1L;

    protected String id;

    /**
     * 备注信息
     */
    private String remarks;


    /**
     * 创建者
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
//    @JsonIgnore
    protected String createBy;

    /**
     * 创建日期
     */
    @TableField(value = "create_date", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date createDate;

    /**
     * 更新者
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
//    @JsonIgnore
    protected String updateBy;

    /**
     * 更新日期
     */
    @TableField(value = "update_date", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    protected Date updateDate;

    /**
     * 0正常，1删除
     */
    @JSONField(serialize = false)
    @TableField(value = "del_flag", fill = FieldFill.INSERT)
    @TableLogic
    @JsonIgnore
    protected String delFlag;


    public BasePlusEntity(String id) {
        this();
        this.id = id;
    }

    public BasePlusEntity() {
    }


}
